<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/vue.min.js"></script>
    <script type="text/javascript" src="js/axios.min.js"></script>
</head>
<body style="background-color: #a2d4ca">
    <div class="container" id="login">
        <div class="content" style="width: 400px;margin: 200px auto;background-color: #a4e2f8;padding: 0 0 10px 0;border-radius: 5px">
            <span style="display: block;padding: 5px;text-align: center;background-color: #21bbf5;margin-bottom: 20px;font-size: 20px">管理员登录</span>
            <span style="display: block;text-align: center;margin-bottom: 20px;color: red">{{msg}}</span>
            <form class="form-horizontal" action="login" method="post" @submit.prevent="login2" ref="export">
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-3 control-label">登录名</label>
                    <div class="col-sm-8">
                        <input v-model="loginName"  type="text" class="form-control" id="inputEmail3" placeholder="请输入登录名">
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputPassword3" class="col-sm-3 control-label">密　码</label>
                    <div class="col-sm-8">
                        <input v-model="password" type="password" class="form-control" id="inputPassword3" placeholder="请输入密码">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-5 col-sm-7">
                        <button type="submit" class="btn btn-default">登录</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</body>
<script>
    new Vue({
        el:'#login',
        data:{
            loginName:'',
            password:'',
            msg:''
        },
        created:function () {

        },
        methods:{
            login2:function () {
                //判断是否有空值或空格
                var input  = /^[\s]*$/
                if (input.test(this.loginName)){
                    this.msg='登录名不能为空'
                }else if (input.test(this.password)){
                    this.msg='密码不能为空'
                }else{
                    axios.post('adminInfo/queryAdmin',{
                        "adminName":this.loginName,
                        "adminPwd":this.password
                    }).then((response)=>{
                        if (response.data.code=='0'){
                            this.msg = "用户名或密码错误"
                        }else {
                            // console.log("dsdfs")
                            this.$refs.export.submit()
                        }
                    })

                }
            },
            onInput:function () {
                this.msg=''
            }
        }
    })
</script>
</html>